var ad_width = "100px";
var add_height = "250px";
var ad_img = "img/ad1.jpg";
var ad_bottom_right = "img/ad2.jpg"
var close_img = "img/close.png";

var ad_left = document.createElement("div");
ad_left.style.width = ad_width;
ad_left.style.height = add_height;
ad_left.style.padding = "0px";
ad_left.style.position = "absolute";
ad_left.style.left = "30px";
ad_left.style.top = "20px";


function a(){
    //对联的左边的图片
    var id=document.getElementById("id");
    var img=document.createElement("img");
    img.src= ad_img;

    //关闭的图片
    var id1=document.getElementById("id1");
    var img1=document.createElement("img");
    img1.style.width = "60px";
    img1.style.position = "absolute";
    img1.style.left = "40px";
    img1.style.bottom = "-30px";
    img1.src= close_img;

    //对联的右边
    var id2=document.getElementById("id2");
    var img2=document.createElement("img");
    img2.src= ad_img;

    //关闭的图片
    var id3=document.getElementById("id3");
    var img3=document.createElement("img");
    img3.style.width = "60px";
    img3.style.position = "absolute";
    img3.style.left = "40px";
    img3.style.bottom = "-30px";
    img3.src= close_img;


    //定时器
    setTimeout(function(){
        id.appendChild(img);
        id1.appendChild(img1);
        id2.appendChild(img2);
        id3.appendChild(img3);
    }, 1000);


    //关闭的事件
    id1.onclick = function (){
        img.style.display = 'none';
        img1.style.display = 'none'
        img2.style.display = 'none'
        img3.style.display = 'none'
    }

   //关闭的事件
    id3.onclick = function (){
        img.style.display = 'none';
        img1.style.display = 'none';
        img2.style.display = 'none';
        img3.style.display = 'none';
    }
}
a();

function b(){
   //弹窗广告缓慢出现的动画效果
    var ad = document.getElementById('id4');
    var ad1 =document.getElementById("id5");
    var img4=document.createElement("img");
    var img5=document.createElement("img");

    img4.src= ad_bottom_right;
    img5.src= close_img;

    img5.style.width = "80px";
    img5.style.position = "absolute";
    img5.style.left = "220px";

    id4.appendChild(img4);
    id5.appendChild(img5);
    // 设置初始位置
    var position = -ad.offsetHeight;
    var position1 = -ad1.offsetHeight;
    ad.style.bottom = position + "px";
    ad1.style.bottom = position1 + "px";

    //广告上升
    var upInterval = setInterval(function () {
        position++;
        position1++;
        if (position >= 0 && position1 >= 0) {
            clearInterval(upInterval);
        } else {
            ad.style.bottom = position + "px";
            ad1.style.bottom = position1 + "px";
        }
    }, 10);

    //关闭的事件
    ad1.onclick = function (){
        img4.style.display = 'none';
        img5.style.display = 'none';
    }
}
b();





